<script>
    $('#volume_folder_tb').jqGrid({
        url:'/folder/grid',
        datatype: 'json',
        mtype: 'GET',
        styleUI:'Bootstrap',
        colNames:['编号','名称','[["label state"|translate]]','纠删码','所有者','创建时间','操作'],
        colModel :[
            {name:'id', index:'id', width:20, align:'left',hidden:true},
            {name:'name', index:'name', width:5, align:'left',
                formatter:function(cellvalue,option,row) {
                    return makeEllipsis(cellvalue,option);
                },
                unformat:function(cell) {
                    return cell;
                }
            },
            {name:'status', index:'status', width:6, align:'left'},
            {name:'ec_show', index:'ec_show', width:6, align:'left'},
            {name:'username', index:'username', width:5, align:'left'},
            {name:'created_at', index:'created_at', width:5, align:'left'},        
            {name:'operation', index:'operation', width:5, align:'left',
                detailHidden:true,
                formatter:function(cell,option,row) {
                    var html = '';
                    row = row2object(row,option.gid);
                    //html += '<button title="编辑" class="btn btn-blue" onclick="folder_update('+row['id']+')">编辑</button>';
                    html += '<button style="margin-left:10px;" title="删除" class="btn btn-blue" onclick=folder_delete_confirm('+row['id']+',"'+row['name']+'")>删除</button>';
                    return html;
                }
            }    
        ],
        page:1,
        rowNum :10,
        sortname: 'id',
        sortorder: 'asc',
        viewrecords: true,
//        caption: '所有集群授权信息列表',
        altclass:'ui-priority-secondary',
        // altRows:true,
        multiselectWidth:40,
        altRows:true,
        autowidth:true,
        height:mainpanelHeight,
        gridComplete:function(){
            jqgrid_page($(this), $("#div_folder_available_tb"));
              var ids=$(this).jqGrid('getDataIDs');
              var op_ids=$(this).attr("id");
                for(var i=0; i<ids.length; i++){
                    var status =  $(this).getCell(ids[i], 'status');
                    $(this).jqGrid('setRowData', ids[i], {status: SelfTranslate(status)});
                }
           }             
});
    function folder_delete_confirm(folder_id, folder_name){
            msg = "确认删除文件夹"+folder_name+"?";
            SelfConfirm(msg, folder_delete, folder_id, "删除提示");
        }
    function folder_delete(folder_id){
                  $.ajax({
                    url:"/folder/delete",
                    type:"POST",
                    dataType:"json",
                    data:{'folder_id':folder_id},
                    success:function(data){
                        if (data.reply.is_success){
                            $("#volume_folder_tb").trigger('reloadGrid');
                        }else{
                            error =  data.reply.error;
                            SelfAlert(error);
                        }
                    }
                });
        }
    function folder_update(folder_id) {
        angular.element("#folder_controller").scope().open('/folder/update?folder_id='+folder_id)
    }
    $("#folder_create_button").click(function(){
        angular.element('#folder_controller').scope().open("/folder/create");
    });
</script>


<div class="panel panel-f-style">
    <div class="panel-body" ng-controller="FolderModalCtrl" id="folder_controller">
        <div class="title-tag">
            <h3>文件夹</h3>
            <p>文件夹管理</p>
        </div>
        <div class="grid-tools">
            <div class="grid-operate pull-left">
                <button class="btn btn-blue" type="button" id="folder_create_button">创建</button>
            </div>
        </div>
        <div class="grid-body" id="gridttt">
            <table id="volume_folder_tb"></table>
        </div>
    </div>
</div>

